<?php

namespace App\Http\Requests;

use Illuminate\Foundation\Http\FormRequest;



class UserRegister extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        return [
            'name' => 'required|min:3|max:120|alpha_num',
            'pass' => 'required|min:6',
        ];
    }

    public function messages()
    {
        return [
           'name.required' => '用户名不能为空',
           'name.min'  => '用户名长度最小为3个字符',
           'name.max' => '用户名长度最长为120个字符',
           'name.alpha_num' => '用户名只能是数字、字母',
           'pass.required' => '密码不能为空',
           'pass.min' => '密码过短，至少6位',
        ];
    }
}
